import ElFormDialog from "./el-form-dialog.vue";
import type {ElFormItem} from "@/components/AForm/types";
import {ElFormDialogInstance} from "@/components/AForm/data";

export const useFormDialog=(
  addApi:(data:any)=>Promise<any|undefined>,
  updApi:(data:any)=>Promise<any|undefined>,
  formItems:ElFormItem[],
  onOk:(res?:any)=>void,
  artherProp?:any
)=>{
  const formRef=ref<ElFormDialogInstance>()
  const vnode=()=>h(
    ElFormDialog,
    {
      ref:formRef,
      addFunction:addApi,
      updateFunction:updApi,
      formItems:formItems,
      onOk,
      ...artherProp
    }
  )
  return{
    form:vnode,
    formRef,
  }
}
